terraform {
  required_version = ">= 0.14"

  required_providers {
    jenkins = {
      source = "taiidani/jenkins"
      version = "0.9.0"
    }
  }
}

provider "jenkins" {
  server_url = "http://jenkins.jq.cn" # Or use JENKINS_URL env var
  username   = "admin"                 # Or use JENKINS_USERNAME env var
  password   = "1"                 # Or use JENKINS_PASSWORD env var
  ca_cert    = ""                      # Or use JENKINS_CA_CERT env var
}

module "ci" {
  source = "../"

  jobs = [
    {
      name: "ebike"
      template: templatefile("${path.module}/pipeline.xml.tpl", {
          description = "An example pipeline job as Terraform"
      })
    },
    {
      name: "worker"
      template: templatefile("${path.module}/pipeline.xml.tpl", {
        description = "An example pipeline job as Terraform"
      })
    },
    {
      name: "mbserver"
      template: templatefile("${path.module}/pipeline.xml.tpl", {
        description = "An example pipeline job as Terraform"
      })
    },
    {
      name: "device"
      template: templatefile("${path.module}/pipeline.xml.tpl", {
        description = "An example pipeline job as Terraform"
      })
    },
  ]
}